import java.awt.Dimension;
import java.util.Vector;

import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JToolBar;

public class MyToolBar extends JToolBar {
	public JComboBox selectDB;
	
	public MyToolBar(Vector database) {
		addToolBarButtons();
		addToolBarSelectDatabase(database);
	}

	public void addToolBarButtons() {
		JButton button;

		button = makeNavigationButton("New Query", "query", "toolbar_newquery",
				"New Query", "New Query");
		button.addActionListener(new Client.ItemListener());
		add(button);

		button = makeNavigationButton("Execute", "play", "toolbar_execute",
				"Execute Query", "Execute Query");
		button.addActionListener(new Client.ItemListener());
		add(button);

		button = makeNavigationButton("", "open", "toolbar_open", "Open File", "Open");
		button.addActionListener(new Client.ItemListener());
		add(button);

		button = makeNavigationButton("", "save", "toolbar_save", "Save", "Save");
		button.addActionListener(new Client.ItemListener());
		add(button);
	}

	public JButton makeNavigationButton(String btnText, String imageName,
			String actionCommand, String toolTipText, String altText) {
		String imgLocation = "res/images/" + imageName + ".gif";
		// Create and initialize the button.
		JButton button = new JButton(btnText);
		button.setActionCommand(actionCommand);
		button.setToolTipText(toolTipText);
		button.setIcon(new ImageIcon(imgLocation, altText));
		return button;
	}
	
	public void addToolBarSelectDatabase(Vector database) {
		selectDB = new JComboBox();
		selectDB.setMaximumSize(new Dimension(100,25));
		selectDB.setSize(new Dimension(100,20));
		for (int i=0; i<database.size(); i++) {
			String userDatabase = (String)database.elementAt(i);
			selectDB.addItem(userDatabase);
		}
		add(selectDB);
	}
}